<%--
  Created by IntelliJ IDEA.
  User: 14364
  Date: 2023/1/3
  Time: 19:40
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="../static/bootstrap-5.1.3-dist/css/bootstrap.css">
    <script type="text/javascript" src="../static/bootstrap-5.1.3-dist/js/bootstrap.js"></script>
    <title>领养帖子管理</title>
</head>
<style>
    body {
        margin: auto;
        width: 100%;
    }

    .card {
        width: 2000px;
        height: 700px;
        background-color: #fffdfd;
        margin-left: 120px;
        margin-top: 30px;
        border-radius: 30px;
        border: none;
        box-shadow: 5px 5px 10px #adabab;
    }

    .operate {
        padding: 20px 50px;
    }

    .operate button {
        border: solid;
        width: 150px;
    }

    .operate a {
        width: 150px;
    }

    table {
        text-align: center;
        vertical-align: middle !important;
        word-wrap: break-all;
        word-break: break-all;
        table-layout: fixed;
    }


    table img {
        width: 100px;
        height: 100px;
    }

    table .caozuo a {
        margin: 0 15px;
        width: 100px;
    }

    .page {
        height: 50px;
        width: 1270px;
        position: fixed;
        bottom: 100px;
    }

    li {
        list-style: none;
    }
</style>
<body>
<jsp:include page="../static/Page/Admin/User/head.jsp"/>
<div class="container text-center">
    <div class="row">
        <div class="">
            <jsp:include page="../static/Page/common/AdminNav.jsp"/>
        </div>
        <div class="card">
            <div class="tab-pane fade" id="v-pills-profile" role="tabpanel" aria-labelledby="v-pills-profile-tab"
                 tabindex="0"></div>

            <form class="operate" method="get" action="post_list">
                <div class="row">
                    <input name="method" value="query" class="input-text form-control" type="hidden">
                    <div class="col-md-4">
                        <input type="text" class="form-control" placeholder="请输入内容" name="postKeys" value="${postKey}"
                               autocomplete="on">
                    </div>
                    <input type="hidden" name="page" value="1"/>
                    <div class="col-md-2">
                        <button type="submit" class="btn btn-outline-secondary">搜 索</button>
                    </div>

                </div>
            </form>

            <table id="post" class="table table-bordered table-striped ">
                <colgroup>
                    <col style="width:10%;">
                    <col style="width:10%;">
                    <col style="width:20%;">
                    <col style="width:15%;">
                    <col style="width:20%;">
                </colgroup>
                <thead>
                <tr>
                    <th>头像</th>
                    <th>发帖人</th>
                    <th>主题</th>
                    <th>时间</th>
                    <td>操作</td>
                </tr>
                </thead>
                <tbody>
<%--                <c:forEach items="${posts}" var="post" varStatus="s">--%>
<%--                            <tr>--%>
<%--                                <td>--%>
<%--                                    <img src="${pageContext.request.contextPath}/display?photo=${user.photo}" style="width: 100px;height: 100px">--%>
<%--                                </td>--%>
<%--                                <td>${user.username}</td>--%>
<%--                                <td>${post.title}</td>--%>
<%--                                <td>${post.date}</td>--%>
<%--                                <td class="caozuo">--%>
<%--                                    <c:if test="${post.status==1}">--%>
<%--                                        <a href="post_ban?postid=${post.id}&postKeys=${postKey}&page=${pageInfo.pageIndex}" type="button" class="btn btn-outline-warning"type="button" class="btn btn-outline-warning">封禁</a>--%>
<%--                                    </c:if>--%>
<%--                                    <c:if test="${post.status==2}">--%>
<%--                                        <a href="post_ban?postid=${post.id}&postKeys=${postKey}&page=${pageInfo.pageIndex}" type="button" class="btn btn-outline-success">解封</a>--%>
<%--                                    </c:if>--%>
<%--                                </td>--%>
<%--                            </tr>--%>
<%--                </c:forEach>--%>

                <c:forEach items="${posts}" var="post" varStatus="s">
                    <c:forEach items="${userList}" var="user" varStatus="u">
                        <c:if test="${post.userid==user.id}">
                            <tr>
                                <td>
                                    <img src="${pageContext.request.contextPath}/display?photo=${user.photo}" style="width: 100px;height: 100px">
                                </td>
                                <td>${user.username}</td>
                                <td>${post.title}</td>
                                <td>${post.date}</td>
                                <td class="caozuo">
                                    <c:if test="${post.status==1}">
                                        <a href="post_ban?postid=${post.id}&postKeys=${postKey}&page=${pageInfo.pageIndex}" type="button" class="btn btn-outline-warning"type="button" class="btn btn-outline-warning">封禁</a>
                                    </c:if>
                                    <c:if test="${post.status==2}">
                                        <a href="post_ban?postid=${post.id}&postKeys=${postKey}&page=${pageInfo.pageIndex}" type="button" class="btn btn-outline-success">解封</a>
                                    </c:if>
                                </td>
                            </tr>
                        </c:if>
                    </c:forEach>
                </c:forEach>

                </tbody>
            </table>

            <div class="page">
                <nav aria-label="Page navigation example">
                    <ul class="pagination justify-content-between">
                        <c:if test="${pageInfo.isLast && falg == null}">
                            <li><a href="post_list?page=${pageInfo.pageIndex-1}&postKeys=${postKey}" class="page-link"><span
                                    aria-hidden="true">&larr;</span> 上一页</a></li>
                        </c:if>
                        <c:if test="${pageInfo.isNext && falg == null}">
                            <li><a href="post_list?page=${pageInfo.pageIndex+1}&postKeys=${postKey}" class="page-link">下一页 <span
                                    aria-hidden="true">&rarr;</span></a></li>
                        </c:if>
                    </ul>
                    <span>第 ${pageInfo.pageIndex} 页/共 ${pageInfo.sumCount} 页</span>
                </nav>
            </div>



        </div>
    </div>
</div>
</body>
</html>